/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Andy
 */

@NamedQueries({
    @NamedQuery(name = "BasisReis.getAllBasisReis", query = "select b from BasisReis b"),
        @NamedQuery(name = "BasisReis.getBasisReisById", query = "select b from BasisReis b where b.id=:id"),

    @NamedQuery(name = "BasisReis.getAllBasisReisBasic", query = "select b from BasisReis b where b.beginDatum like :vertrekdatum AND b.eindDatum like :einddatum AND b.bestemming.id like :bestemming AND b.vertrek.id like :vertrekplaats"),
    //@NamedQuery(name = "BasisReis.getAllBasisReisBasic", query = "select b from BasisReis b where b.beginDatum like '%' AND b.eindDatum like '%' AND b.bestemming.id like '%' AND b.vertrek.id like '%'"),
    @NamedQuery(name = "BasisReis.getAllBasisReisBasicByBestemming", query = "select b from BasisReis b where b.bestemming = :bestemming")
})

@Entity
@Table(name="BasisReis")
public class BasisReis implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @NotNull
    @ManyToOne
    private Stad vertrek;
    @NotNull
    @ManyToOne
    private Stad bestemming;
    private double prijsPerPersoon;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date beginDatum;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date eindDatum;
    @OneToMany
    private List<Boeking> boekingen = new ArrayList<Boeking>();

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Stad getVertrek() {
        return vertrek;
    }

    public void setVertrek(Stad vertrek) {
        this.vertrek = vertrek;
    }

    public Stad getBestemming() {
        return bestemming;
    }

    public void setBestemming(Stad bestemming) {
        this.bestemming = bestemming;
    }

    public double getPrijsPerPersoon() {
        return prijsPerPersoon;
    }

    public void setPrijsPerPersoon(double prijsPerPersoon) {
        this.prijsPerPersoon = prijsPerPersoon;
    }

    public Date getBeginDatum() {
        return beginDatum;
    }

    public void setBeginDatum(Date beginDatum) {
        this.beginDatum = beginDatum;
    }

    public Date getEindDatum() {
        return eindDatum;
    }

    public void setEindDatum(Date eindDatum) {
        this.eindDatum = eindDatum;
    }

    public List<Boeking> getBoekingen() {
        return boekingen;
    }

    public void setBoekingen(List<Boeking> boekingen) {
        this.boekingen = boekingen;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BasisReis)) {
            return false;
        }
        BasisReis other = (BasisReis) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.BasisReis[ id=" + id + " ]";
    }
    
}
